# Importing Data
GLOBAL<- read_excel("C:/users/Biniam/Desktop/Documents/Academic/Thesis/Analysis Folder/Excel Files/Plastic/Plastics.xlsx",sheet = "Sheet3", range = "b1:b70")

# Checking the Imported Data
View(GLOBAL)
# Creating Time Series Data
GLOBAL_ts <- ts(GLOBAL, start=c(1950), end=c(2015), frequency=1)
# Viewing and Checking the Created Time Series Data
GLOBAL_ts
sum(is.na(GLOBAL_ts))
library(forecast)
GLOBAL_ts <- tsclean(GLOBAL_ts)
GLOBAL_ts

# Identification: Plotting the Time Series Data
plot(GLOBAL_ts)

# Estimating the appropriate model
GLOBAL_ts_model <- auto.arima(GLOBAL_ts)
GLOBAL_ts_model

# Forecasting
options(max.print=1000000)
GLOBAL_ts_forecast <- forecast (GLOBAL_ts_model, level=c(95), h=25)
plot(GLOBAL_ts_forecast)
GLOBAL_ts_forecast             

# Exporting
write.table(GLOBAL_ts_forecast, file="/users/Biniam/Desktop/Documents/Academic/Thesis/Result Folder/TSA Results/Excel Files/From R/Plastic/GLOBAL_TSA.csv", sep=",")


